def CheckBrotherStr():
    List = list(input().split(" "))
    L1 = List[1:int(List[0]) + 1]
    L2 = []
    Str1 = List[int(List[0]) + 1]
    for i in range(0, len(L1)):
        if L1[i] != Str1:
            if sorted(Str1) == sorted(L1[i]):
                L2.append(L1[i])
    print(len(L2))
    if len(L2) > 1:
        print(sorted(L2)[int(List[-1]) - 1])
    else:
        print(L2[0])

CheckBrotherStr() 